import os

import cv2

video_path = "/home/lism/Pictures/DJI_0031.MP4"

output_foler = "frames/input"

os.makedirs(output_foler, exist_ok=True)

cap = cv2.VideoCapture(video_path)
frame_count = 0

while True:
    ret, frame = cap.read()
    if not ret:
        break
    frame_filename = f"{output_foler}/frame_{frame_count:06d}.png"

    if frame_count % 60 == 0:
        cv2.imwrite(frame_filename, frame)
    frame_count += 1

cap.release()
cv2.destroyAllWindows()

print(f"success splite {frame_count} frame")
